const Router = require('koa-router')
const TypeController = require('../controllers/type.controller')
const jwt = require('../middlewares/jwt.middleware')
const isRole = require('../middlewares/role.middleware')

const router = new Router()
const typeController = new TypeController()
router.prefix('/api/types')

router.get('/', jwt, typeController.findAll)

router.post('/', jwt, isRole(['admin']), typeController.addOne)

router.get('/:id', jwt, typeController.findOne)

router.patch('/:id', jwt, isRole(['admin']), typeController.updateOne)

router.delete('/:id', jwt, isRole(['admin']), typeController.deleteOne)

module.exports = router